<?php
class EditBook extends Zend_Form {
	
	private $userBook;
	private $book;
	
	public function EditBook($userBook, $book) {
		$this->userBook = $userBook;
		$this->book = $book;
		$this->__construct();
	}
	
	public function init() {
		$this->setMethod("POST");
		
		$element = new Zend_Form_Element_Hidden("ASIN");
        $element->setValue($this->book->ASIN);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("detail_page_url");
        $element->setValue($this->book->detail_page_url);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("name");
        $element->setValue($this->book->name);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("description");
        $element->setValue($this->book->description);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("ISBN");
        $element->setValue($this->book->ISBN);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("ISBN13");
        $element->setValue($this->book->ISBN13);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("small_image");
        $element->setValue($this->book->small_image);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("medium_image");
        $element->setValue($this->book->medium_image);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("large_image");
        $element->setValue($this->book->large_image);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("currency");
        $element->setValue($this->book->currency);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("amount");
        $element->setValue($this->book->amount);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("author");
        $element->setValue($this->book->author);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("binding");
        $element->setValue($this->book->binding);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("manufacturer");
        $element->setValue($this->book->manufacturer);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("number_of_pages");
        $element->setValue($this->book->number_of_pages);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("publication_date");
        $element->setValue($this->book->publication_date);
        $element->removeDecorator('Label');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Hidden("publisher");
        $element->removeDecorator('Label');
        $element->setValue($this->book->publisher);
        $this->addElement($element);
        
        
		$this->addDisplayGroup(array('publisher', 'publication_date','number_of_pages','manufacturer',
		'binding','author','amount','currency','large_image','medium_image','small_image',
		'ISBN13','ISBN','description','name','detail_page_url','ASIN'),'hiddenBookInfo')->removeDecorator('Label');;
        
        $element = new Zend_Form_Element_MultiCheckbox("condition");
        $element->setLabel("Condition");
        $element->setMultiOptions(array(
            "1" => "New",
            "2" => "Used",
            "3" => "EBook"
        ));
        $element->setValue(explode(",", $this->userBook->condition));
        $element->setSeparator('');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_MultiCheckbox("usage");
        $element->setLabel("Usage");
        $element->setMultiOptions(array(
            "1" => "For sale",
            "2" => "For rent",
            "3" => "For exchange",
            "4" => "For giveaway"
        ));
        $element->setValue(explode(",", $this->userBook->usage));
        $element->setSeparator('');
        $this->addElement($element);
        
        $element = new Zend_Form_Element_Textarea("note");
        $element->setAttrib('rows', 3)->setAttrib('cols', 30);
        $element->setLabel("Message");
        $element->setDescription('Describe more about this book\'s situation, e.g - "How much do you sell it?"  - "Which kind of book do you want to exchange?" - "How to rent it?"');
        $element->setValue($this->userBook->note);
        $this->addElement($element);
        
/*        $element = new Zend_Form_Element_Select("status");
        $element->setLabel("Status");
        $element->addMultiOptions(array(
                    'available' => 'Available',
                    'sold' => 'Sold',
                    'letout' => 'Letout',
                    'invalid' => 'Invalid'
            ));
        $element->setValue($this->userBook->status);   
        $this->addElement($element); */
        
        $element = new Zend_Form_Element_Submit("save");
        $element->setLabel("save");
        $element->removeDecorator('Label');
        $this->addElement($element);
	}
}
?>